<template>
  <div class="select-body">
    <h3>请上传身份证照片</h3>
    <div class="card">
      <div class="card-box card-left" :style="leftStyle">
        <van-icon name="photo-o" size="22" color="#fff" />
        <span>上传身份证正面</span>
      </div>
      <div class="card-box card-right" :style="rightStyle">
        <van-icon name="photo-o" size="22" color="#fff" />
        <span>上传身份证正面</span>
      </div>
    </div>
    <div class="card bottom">
      <h3>请上传身份证照片</h3>
      <div class="card-bottom" :style="bottomStyle">
        <van-icon name="photo-o" size="22" color="#fff" />
        <span>上传身份证正面</span>
      </div>
    </div>
    <p>(demo程序)敏感信息，无需上传</p>
    <van-button type="primary" size="large" @click="handleNext">下一步</van-button>
  </div>
</template>

<script>
export default {
  mounted() {
    this.cardType = this.$route.params.card;
    // this.leftStyle = 'background:' + require(`@/assets/card_${this.cardType}.png`)
    this.leftStyle = {
      backgroundImage:
        "url(" + require(`@/assets/card_${this.cardType}.png`) + ")",
    };
    this.rightStyle = {
      backgroundImage: "url(" + require(`@/assets/card_back.png`) + ")",
    };
    this.bottomStyle = {
      backgroundImage: "url(" + require(`@/assets/card_hand.png`) + ")",
    };
  },
  data() {
    return {
      cardType: "",
      leftStyle: "",
      rightStyle: "",
      bottomStyle: "",
    };
  },
  methods: {
    async handleNext() {
      console.log('here');
      const toast = this.$toast.loading('正在上传，请稍后')
      await new Promise(resolve => {
        setTimeout(() => {
          toast.clear()
          resolve()
        }, 1000);
      })
      this.$router.push({name: 'userInfo'})
    }
  },
};
</script>

<style lang="scss" scoped>
.select-body {
  display: flex;
  flex-direction: column;
  padding: 20px;
  justify-content: center;
  align-items: center;
  h3 {
    font-family: PingFang SC;
    font-weight: 500;
    color: #333333;
    align-self: flex-start;
    margin-bottom: 30px;
  }
  .card {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    border-bottom: 1px solid #eee;
    padding-bottom: 40px;
    .card-box {
      flex: 1;
      display: flex;
      background-repeat: no-repeat;
      background-size: 100% 100%;
      height: 113px;
      justify-content: center;
      align-items: center;
      span {
        color: #fff;
      }
    }
    .card-left {
      margin-right: 20px;
    }
  }
  .bottom {
    padding-top: 40px;
    flex-direction: column;
    border: none;
    .card-bottom {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 170px;
      background-size: 100% 100%;
      span {
        color: #fff;
      }
    }
  }
}
</style>